	var CG = {};
	CG.util = {
	CacheProxy:function(json){
		this.json = json;
		this.getCachedData = function(name){
		
			return json[name];
		}
		
	},
	
	CacheClient:function(){
		this.getCachedData = function(name){
			return window.parent.cacheProxy.getCachedData(name);
		}
	},
	
	LocalSimpleDataSet:function(data){
	  	this.data = data;
	  	this.map = {}
	  	for(var i=0;i<data.length;i++){
		  	this.map[data[i][0]+""]= data[i][1]
	  	}
	  	
	  	this.getDisplayValue = function(key){
	  		
	      	return this.map[key];
	  	}
	
		this.getDisplayValue = function(key,defaultValue){
	  		
	      return this.map[key]==null?defaultValue:this.map[key];
	      	
	  	}
	
	  	this.all = function(){
	  	  	return this.data;
	  	}
	  	this.getStore = function(){
			
	  		return new Ext.data.ArrayStore({
	            id: 0,
	            fields: ['id', 'displayText'],
	            data: data
	        })
	  	}
	  
	},
	
	RemoteSimpleDataSet:function(url,idMapping,idType,valueMapping, valueType,descriptionMapping){
	
	
		var fields =  [
		       	     	    {name:'id', type: idType,mapping:idMapping}, 
		    	     	    {name:'displayText', type: valueType,mapping:valueMapping}
		    		  ]
		if(descriptionMapping!=null){
			fields.push({name:'desc', type: "string",mapping:descriptionMapping});
		}
	
		
		 this.store = new Ext.data.Store({
		        reader: new Ext.data.JsonReader({
		            fields: fields
		        }),
		        proxy:new Ext.data.HttpProxy({
		            url: url
		        })
		  });
		var lock = true;
		this.store.load({
			callback: function (r, options, success) {
	            if (success == false) {
	                alert("load false");
	            } else {
	            	lock = false;
	            }
	       
	    	}
	
			});	
	
		
				this.getDisplayValue = function(key){
			/*
				while(lock){
		  		console.log("lock")
	  		}
	  		*/
	      	var index = this.store.findExact("id",key,0);
	      	if(index==-1){
		      	return "Not Found In EXT CG";
	      	}
	      	else{
		      	return this.store.getAt(index).data["displayText"];
	      	}
	  	}
	
		
	
	  	this.reload = function(options){
		  	this.store.reload(options);
	  	}
	
	  	this.all = function(){
	  	  	return this.store;
	  	}
	  	this.getStore = function(){
			return 	this.store;
	  	}
	  
	},
			
	moveToGrid:function (rec,form){
		
		
		var items = rec.store.fields.items;
		for(var i=0;i<items.length;i++){
			
			var vname = items[i].name;
			var temp = form.findField(vname);
			
			if(temp!=null){
				var value = form.findField(vname).getValue();
				rec.set(vname,value);
			}
				
			
			
		}
		
		rec.commit();
	},
	
	addToGrid:function (grid,form){
		var values = form.getValues();	
		var model = {};
		var items = grid.getStore().fields.items;
		var blankRecord = Ext.data.Record.create(grid.getStore().fields);
		var rec = new blankRecord({});
		for(var i=0;i<items.length;i++){	
			var vname = items[i].name;
			var temp = form.findField(vname);
			if(temp!=null){
				var value = form.findField(vname).getValue();
			
				rec.set(vname,value);
			}
			
		}	
		grid.getStore().insert(grid.getStore().getCount(),rec);	
		grid.getStore().commitChanges();
	},
	
	setForm: function (o, form, filedPrefix) {
	    if (!filedPrefix) filedPrefix = "";
	    //console.log("................parse:"+filedPrefix);
	    
	    for (id in o) {
	        var f = o[id];
	        if (!Ext.isEmpty(f)) {
	            if (Ext.isObject(f)) {
	            	field = form.findField(filedPrefix + id);
	            	if(!Ext.isEmpty(field) ){
	            		//注意这里的cztype是自定义的。
	            		if(field.getXType() =="datefield" || field.cztype=="date"){
	            			field.setValue(f.$);
	            		}
	            	}
	            	else{
		                CG.util.setForm(f, form, filedPrefix+id + ".");
		            }
	
	            } else {
	                field = form.findField(filedPrefix + id);
	
	                if (!Ext.isEmpty(field)) {
	                    //console.log(filedPrefix+id+"="+f);
	                   
	                    field.setValue(f);
						//alert(field.vtype);
	                } else {
	                    ////console.log("find null field:"+filedPrefix+id);
	                }
	
	            }
	        } else {
	            ////console.log("find null value:"+filedPrefix+id);
	        }
	
	    }
	
	},
	
	/*得到url参数的某个值2*/
	GetQueryString:function(name) {
	
	    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	
	    var r = window.location.search.substr(1).match(reg);
	
	    if (r != null) return unescape(r[2]);
	    return "";
	},
	timeFormat:function(ptime,f){
		if(Ext.isEmpty(ptime))
			return '';
		else{
			//2020-01-01 10:20:20.0
			var re ;
			if(Ext.isEmpty(f))
				f == "YMD";
			if(f=="YMD")
				re=/\d{4}-\d{2}-\d{2}/;
			else if(f=="YMDhm")
				re=/\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}/;
			else if(f=="YMDhms")
				re=/\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}/;
			else
				re=/\d{4}-\d{2}-\d{2}/;
			var r = ptime.match(re);
			return r;
		}
	},
	setWidth:function(pname,pscroll,psource){
			var lw = 215+15+2;//左div宽度,间隔,左边距
			var w = document.body.clientWidth;
			var rw = w-lw;

			if(pscroll){
				if(psource!="first"){					
					if(Ext.isIE6){
						rw = rw-20;
					}
				}else{
					rw = rw-20;
				}
			}
			
			//alert(rw);
			var contentright = document.getElementById(pname);
			
			contentright.style.left = lw+"px";
			contentright.style.width=rw+"px";
		
	},
	addEmptyText:function(pcombo){
		var store = pcombo.getStore();
		var emptyText = pcombo.emptyText;
		if(Ext.isEmpty(emptyText))
			emptyText = "请选择";
		var displayfield=pcombo.displayField;
		var valueField=pcombo.valueField;
		
		var empR = new Ext.data.Record.create([{name:valueField},{name:displayfield}]);
		var myR = eval("new empR({"+valueField+":'',"+displayfield+":'"+emptyText+"'})");
		store.insert(0,myR);	
	}
	
	}